using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class boom : MonoBehaviour
{
    public float skilltime;
    public float preparetime;
    public bool skillend;
    public int boomtimes;
    GameObject canvas;
    public GameObject missle;
    // Start is called before the first frame update
    public void Start()
    {
        skillend = false;
        canvas = transform.GetChild(0).gameObject;
        Skill();
    }

    // Update is called once per frame
    public IEnumerator Skilling()
    {

        for(int i = 1; i <= boomtimes; i++)
        {
            yield return new WaitForSeconds(skilltime);
            Vector3 position = transform.position;
            position.y = 20;
            position.x = position.x + Random.Range(-2.5f, 2.5f);
            Instantiate(missle, position, Quaternion.identity);

        }
        Destroy(gameObject);
    }
    public IEnumerator preparing()
    {
        yield return new WaitForSeconds(preparetime);
        canvas.SetActive(false);
        StartCoroutine(Skilling());

    }
    public void Skill()
    {
        canvas.SetActive(true);
        StartCoroutine(preparing());
    }
}
